import React from 'react'
import { connect } from 'react-redux'
import { Link, withRouter } from 'react-router-dom'
import { Breadcrumb } from 'antd'
import './index.scss'

const BreadCrumb = (props) => {
  const extraBreadcrumbItems = props.currentMenuList.map((item) => {
    return (
      <Breadcrumb.Item key={ item.path }>{ item.title }</Breadcrumb.Item>
    )
  })
  
  const breadcrumbItems = [
    <Breadcrumb.Item key="home">
      <Link to="/">首页</Link>
    </Breadcrumb.Item>,
  ].concat(extraBreadcrumbItems)

  return (
    <div className="app-breadcrumb">
      <Breadcrumb style={{ lineHeight: '64px' }}>{breadcrumbItems}</Breadcrumb>
    </div>
  )
}

const mapStateToProps = state => {
  return {
    ...state.app
  }
}

export default connect(mapStateToProps)(withRouter(BreadCrumb))
